<%--
  Created by IntelliJ IDEA.
  User: 3353611694
  Date: 2022/5/17
  Time: 16:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>添加届别</title>
    <%--    引入css、js--%>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css"/>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-3.5.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ajaxForm.js"></script>

    <script>
        layui.use(['form', 'laydate', 'layer'], function () {
            var form = layui.form, laydate = layui.laydate, layer = layui.layer;
            //定义自定义验证规则
            form.verify({
                v_notallnum:function (val,item) {
                    if (/^\d+\d+\d$/.test(val)){
                        return "内容不能全为数字"
                    }
                },
                v_pass:[
                    /^[\S]{6,12}$/,
                    '长度需要在6-12之间'
                ]
            });
            laydate.render({
                elem:'#datetime',
                type:'date' //指定
            });
            laydate.render({
                elem:'#datetime2',
                type:'date' //指定
            });
            laydate.render({
                elem:'#datetime3',
                type:'date' //指定
            });
            //监听表单的提交
            <%--form.on('submit(formBtn)',function () {--%>
            <%--    $("#form1").ajaxSubmit({--%>
            <%--        type: 'post',--%>
            <%--        url:'${pageContext.request.contextPath}/emp/addemp',--%>
            <%--        // success:function (d) {--%>
            <%--        //     var index = parent.layer.getFrameIndex(window.name);--%>
            <%--        //--%>
            <%--        //     form.render();--%>
            <%--        // }--%>
            <%--    });--%>
            <%--    parent.layer.close(index);--%>
            <%--    parent.layui.table.reload('dome');--%>
            <%--});--%>
            //监听表单的提交
            form.on('submit(formBtn)',function(data){
                var formData = new FormData($("#formsbt")[0]);
                $.ajax({
                    url:'${pageContext.request.contextPath}/juris/upjiebie',
                    type : 'POST',
                    data : formData,
                    cache: false,
                    async: false,
                    processData : false,  //必须false才会避开jQuery对 formdata 的默认处理
                    contentType : false,  //必须false才会自动加上正确的Content-Type
                    success:function(data){
                        layer.msg('添加成功！',{icon:6,offset:"auto",time:2000});//提示框
                        setTimeout(function(){
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);//关闭弹出层
                            parent.location.reload("demo");//重新加载父页面表格
                        }, 1100);
                    }
                })
                return false;
            });
        });
    </script>
</head>
<body>
<form class="layui-form" id="formsbt"  lay-filter="form1" enctype="multipart/form-data" >
    <%--届别编号--%>
    <input type="hidden" name="fallId"  class="layui-input" value="${stu.fallId}" />

    <%--    届别名称--%>
    <div class="layui-form-item">
        <label class="layui-form-label" >届别名称：</label>
        <div class="layui-input-inline">
            <input type="text" name="level" class="layui-input" placeholder="请输入姓届别名称" value="${stu.level}"/>
        </div>
    </div>

    <%--    届别名称--%>
    <div class="layui-form-item">
        <label class="layui-form-label" >说明：</label>
        <div class="layui-input-inline">
            <input type="text" name="remark" class="layui-input" placeholder="请输入姓说明" value="${stu.remark}"/>
        </div>
    </div>


    <%--        提交--%>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="formbtn" class="layui-btn" lay-submit lay-filter="formBtn">确认修改</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
</html>
